package com.xbongbong.paas.print.model.impl;

import com.xbongbong.paas.domain.dao.PaasKitPrintTemplateDao;
import com.xbongbong.paas.domain.entity.PaasKitPrintTemplateEntity;
import com.xbongbong.paas.print.model.PaasKitPrintTemplateModel;
import com.xbongbong.paas.toolbox.util.DateUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 套打model
 *
 * @author hongxiao
 * @date 2021-01-18 15:16
 */
@Service("paasKitPrintTemplateModel")
public class PaasKitPrintTemplateModelImpl implements PaasKitPrintTemplateModel {
    @Resource
    private PaasKitPrintTemplateDao paasKitPrintTemplateDao;
    @Override
    public Integer insert(PaasKitPrintTemplateEntity entity) {
        long now = DateUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return paasKitPrintTemplateDao.insert(entity);
    }
    @Override
    public Integer update(PaasKitPrintTemplateEntity entity) {
        entity.setUpdateTime((long) DateUtil.getInt());
        return paasKitPrintTemplateDao.update(entity);
    }

    @Override
    public Integer save(PaasKitPrintTemplateEntity entity) {
        if(entity.getId() == null || entity.getId().equals(0L)) {
            return insert(entity);
        }
        return update(entity);
    }

    @Override
    public List<PaasKitPrintTemplateEntity> list(Map<String, Object> params) {
        return paasKitPrintTemplateDao.findEntitys(params);
    }

    @Override
    public PaasKitPrintTemplateEntity getByKey(Long key) {
        return paasKitPrintTemplateDao.getByKey(key);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> params) {
        return paasKitPrintTemplateDao.getEntitysCount(params);
    }

    @Override
    public Integer delete(Long key) {
        return paasKitPrintTemplateDao.deleteByKey(key);
    }

}
